#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
int n;

int main()
{
    cin >> n;
    string order;
    cin >> order;
    int key = 1;
    int a[n + 1];
    for (int i = 1; i <= n; ++i)
    {
        a[i] = i;
    }
    int start = 1;
    int end = min(n, 4);
    for (int i = 0; i < order.size(); ++i)
    {
        if (order[i] == 'U')
        {
            key = (key - 1 - 1 + n) % n + 1;
        }
        else
        {
            key = key % n + 1;
        }

        if (key > end)
        {
            end = key;
            start = end - 3;
        }
        else if (key < start)
        {
            start = key;
            end = start + 3;
        }
    }
    for (int i = start; i <= end; ++i)
    {
        printf("%d ", a[i]);
    }
    printf("\n");
    printf("%d", key);
    return 0;
}